#ifndef SERVICE_H
#define SERVICE_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>

class Service: public QObject
{
    Q_OBJECT

public:
    Service(QObject *parent = 0);
    void callServiceGET(QString url);
    void callServiceDELETE(QString url);
    void callServicePOST(QString url, QString data);

    virtual void onResponse(const QByteArray &response) {
        emit responseReceived(response);
    }

    virtual void onError(QNetworkReply::NetworkError err) {
        emit networkError(err);
    }

public slots:
    void responseHandler(QNetworkReply *finished);

signals:
    void responseReceived(const QByteArray &data);
    void networkError(QNetworkReply::NetworkError err);

private:
    QNetworkAccessManager m_nam;
};

#endif // SERVICE_H
